package xin.javashare.javacollectionsframework;

import java.util.Collections;
import java.util.PriorityQueue;

public class PriorityQueueDemo {

    public static void main(String[] args) {

        PriorityQueue<String> queue1 = new PriorityQueue<>();
        queue1.offer("Oklahma");
        queue1.offer("indiana");
        queue1.offer("Georgia");
        queue1.offer("Texas");

        while (queue1.size() > 0)
            System.out.print(queue1.remove() + " ");


        System.out.print("\n\n----using comparator----------\n");
        PriorityQueue<String> queue2 = new PriorityQueue<>(4, Collections.reverseOrder());
        queue2.offer("Oklahma");
        queue2.offer("indiana");
        queue2.offer("Georgia");
        queue2.offer("Texas");

        while (queue2.size() > 0)
            System.out.print(queue2.remove() + " ");
    }

}
